
'===============================================================================
'  Generated From - VbNet_SQL_dOOdads_BusinessEntity.vbgen
' 
'  ** IMPORTANT  **
'  How to Generate your stored procedures:
' 
'  SQL        = SQL_StoredProcs.vbgen
'  ACCESS     = Access_StoredProcs.vbgen
'  ORACLE     = Oracle_StoredProcs.vbgen
'  FIREBIRD   = FirebirdStoredProcs.vbgen
'  POSTGRESQL = PostgreSQL_StoredProcs.vbgen
'
'  The supporting base class SqlClientEntity is in the Architecture directory in "dOOdads".
'  
'  This object is 'MustInherit' which means you need to inherit from it to be able
'  to instantiate it.  This is very easilly done. You can Override properties and
'  methods in your derived class, this allows you to regenerate this class at any
'  time and not worry about overwriting custom code. 
'
'  NEVER EDIT THIS FILE.
'
'  Public Class YourObject
'    Inherits _YourObject
'
'  End Class
'
'===============================================================================

' Generated by MyGeneration Version # (1.3.0.3)

Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Collections
Imports System.Collections.Specialized

Imports MyGeneration.dOOdads

NameSpace Class_RC

Public MustInherit Class _MATERIALES
	Inherits SqlClientEntity

		Public Sub New() 
			Me.QuerySource = "MATERIALES"
			Me.MappingName = "MATERIALES"
		End Sub

	'=================================================================
	'  Public Overrides Sub AddNew()
	'=================================================================
	'
	'=================================================================
	Public Overrides Sub AddNew()
		MyBase.AddNew()
				
	End Sub
	
	Public Overrides Sub FlushData()
		Me._whereClause = nothing
		Me._aggregateClause = nothing		
		MyBase.FlushData()
	End Sub
	
		
	'=================================================================
	'  	Public Function LoadAll() As Boolean
	'=================================================================
	'  Loads all of the records in the database, and sets the currentRow to the first row
	'=================================================================
	Public Function LoadAll() As Boolean
	
		Dim parameters As ListDictionary = Nothing
		
		
    	Return MyBase.LoadFromSql("[" + Me.SchemaStoredProcedure + "proc_MATERIALESLoadAll]", parameters)
		
	End Function

	'=================================================================
	' Public Overridable Function LoadByPrimaryKey()  As Boolean
	'=================================================================
	'  Loads a single row of via the primary key
	'=================================================================
	Public Overridable Function LoadByPrimaryKey(ByVal CodMaterial As Integer) As Boolean

		Dim parameters As ListDictionary = New ListDictionary()
		parameters.Add(_MATERIALES.Parameters.CodMaterial, CodMaterial)

		
		Return MyBase.LoadFromSql("[" + Me.SchemaStoredProcedure + "proc_MATERIALESLoadByPrimaryKey]", parameters)

	End Function

	#Region "Parameters"
	Protected class Parameters 
		
		Public Shared ReadOnly Property CodMaterial As SqlParameter
			Get
				Return New SqlParameter("@CodMaterial", SqlDbType.Int, 0)
			End Get
		End Property
		
		Public Shared ReadOnly Property CodTipoMaterial As SqlParameter
			Get
				Return New SqlParameter("@CodTipoMaterial", SqlDbType.Int, 0)
			End Get
		End Property
		
		Public Shared ReadOnly Property DescMaterial As SqlParameter
			Get
				Return New SqlParameter("@DescMaterial", SqlDbType.NVarChar, 200)
			End Get
		End Property
		
		Public Shared ReadOnly Property CantExistente As SqlParameter
			Get
				Return New SqlParameter("@CantExistente", SqlDbType.Decimal, 0)
			End Get
		End Property
		
		Public Shared ReadOnly Property CostoMaterial As SqlParameter
			Get
				Return New SqlParameter("@CostoMaterial", SqlDbType.Decimal, 0)
			End Get
		End Property
		
		Public Shared ReadOnly Property CodProveedor As SqlParameter
			Get
				Return New SqlParameter("@CodProveedor", SqlDbType.Int, 0)
			End Get
		End Property
		
		Public Shared ReadOnly Property CantMinima As SqlParameter
			Get
				Return New SqlParameter("@CantMinima", SqlDbType.Int, 0)
			End Get
		End Property
		
		Public Shared ReadOnly Property CantMaxima As SqlParameter
			Get
				Return New SqlParameter("@CantMaxima", SqlDbType.Int, 0)
			End Get
		End Property
		
		Public Shared ReadOnly Property CodUsuario As SqlParameter
			Get
				Return New SqlParameter("@CodUsuario", SqlDbType.Int, 0)
			End Get
		End Property
		
		Public Shared ReadOnly Property FechaActualizacion As SqlParameter
			Get
				Return New SqlParameter("@FechaActualizacion", SqlDbType.DateTime, 0)
			End Get
		End Property
		
	End Class
	#End Region	

	#Region "ColumnNames"
	Public class ColumnNames
		
        Public Const CodMaterial As String = "codMaterial"
        Public Const CodTipoMaterial As String = "codTipoMaterial"
        Public Const DescMaterial As String = "descMaterial"
        Public Const CantExistente As String = "cantExistente"
        Public Const CostoMaterial As String = "costoMaterial"
        Public Const CodProveedor As String = "codProveedor"
        Public Const CantMinima As String = "cantMinima"
        Public Const CantMaxima As String = "cantMaxima"
        Public Const CodUsuario As String = "codUsuario"
        Public Const FechaActualizacion As String = "fechaActualizacion"

		Shared Public Function ToPropertyName(ByVal columnName As String) As String

			If ht Is Nothing Then
			
				ht = new Hashtable
				
				ht(CodMaterial) = _MATERIALES.PropertyNames.CodMaterial
				ht(CodTipoMaterial) = _MATERIALES.PropertyNames.CodTipoMaterial
				ht(DescMaterial) = _MATERIALES.PropertyNames.DescMaterial
				ht(CantExistente) = _MATERIALES.PropertyNames.CantExistente
				ht(CostoMaterial) = _MATERIALES.PropertyNames.CostoMaterial
				ht(CodProveedor) = _MATERIALES.PropertyNames.CodProveedor
				ht(CantMinima) = _MATERIALES.PropertyNames.CantMinima
				ht(CantMaxima) = _MATERIALES.PropertyNames.CantMaxima
				ht(CodUsuario) = _MATERIALES.PropertyNames.CodUsuario
				ht(FechaActualizacion) = _MATERIALES.PropertyNames.FechaActualizacion

			End If
			
			Return CType(ht(columnName), String)
			
		End Function
		
		Shared Private ht  As Hashtable = Nothing		 
	End Class
	#End Region	
	
	#Region "PropertyNames"
	Public class PropertyNames
		
        Public Const CodMaterial As String = "CodMaterial"
        Public Const CodTipoMaterial As String = "CodTipoMaterial"
        Public Const DescMaterial As String = "DescMaterial"
        Public Const CantExistente As String = "CantExistente"
        Public Const CostoMaterial As String = "CostoMaterial"
        Public Const CodProveedor As String = "CodProveedor"
        Public Const CantMinima As String = "CantMinima"
        Public Const CantMaxima As String = "CantMaxima"
        Public Const CodUsuario As String = "CodUsuario"
        Public Const FechaActualizacion As String = "FechaActualizacion"

		Shared Public Function ToColumnName(ByVal propertyName As String) As String

			If ht Is Nothing Then
			
				ht = new Hashtable
				
				ht(CodMaterial) = _MATERIALES.ColumnNames.CodMaterial
				ht(CodTipoMaterial) = _MATERIALES.ColumnNames.CodTipoMaterial
				ht(DescMaterial) = _MATERIALES.ColumnNames.DescMaterial
				ht(CantExistente) = _MATERIALES.ColumnNames.CantExistente
				ht(CostoMaterial) = _MATERIALES.ColumnNames.CostoMaterial
				ht(CodProveedor) = _MATERIALES.ColumnNames.CodProveedor
				ht(CantMinima) = _MATERIALES.ColumnNames.CantMinima
				ht(CantMaxima) = _MATERIALES.ColumnNames.CantMaxima
				ht(CodUsuario) = _MATERIALES.ColumnNames.CodUsuario
				ht(FechaActualizacion) = _MATERIALES.ColumnNames.FechaActualizacion

			End If
			
			Return CType(ht(propertyName), String)
			
		End Function
		
		Shared Private ht  As Hashtable = Nothing
		
	End Class
	#End Region	
	
	#Region "StringPropertyNames"
	Public class StringPropertyNames
		
        Public Const CodMaterial As String = "s_CodMaterial"
        Public Const CodTipoMaterial As String = "s_CodTipoMaterial"
        Public Const DescMaterial As String = "s_DescMaterial"
        Public Const CantExistente As String = "s_CantExistente"
        Public Const CostoMaterial As String = "s_CostoMaterial"
        Public Const CodProveedor As String = "s_CodProveedor"
        Public Const CantMinima As String = "s_CantMinima"
        Public Const CantMaxima As String = "s_CantMaxima"
        Public Const CodUsuario As String = "s_CodUsuario"
        Public Const FechaActualizacion As String = "s_FechaActualizacion"

	End Class
	#End Region		
	
	#Region "Properties" 
		Public Overridable Property CodMaterial As Integer
			Get
                Return MyBase.GetInt(ColumnNames.CodMaterial)
            End Get
            Set(ByVal Value As Integer)
                MyBase.SetInt(ColumnNames.CodMaterial, Value)
            End Set
        End Property

        Public Overridable Property CodTipoMaterial As Integer
            Get
                Return MyBase.GetInt(ColumnNames.CodTipoMaterial)
            End Get
            Set(ByVal Value As Integer)
                MyBase.SetInt(ColumnNames.CodTipoMaterial, Value)
            End Set
        End Property

        Public Overridable Property DescMaterial As String
            Get
                Return MyBase.GetString(ColumnNames.DescMaterial)
            End Get
            Set(ByVal Value As String)
                MyBase.SetString(ColumnNames.DescMaterial, Value)
            End Set
        End Property

        Public Overridable Property CantExistente As Decimal
            Get
                Return MyBase.GetDecimal(ColumnNames.CantExistente)
            End Get
            Set(ByVal Value As Decimal)
                MyBase.SetDecimal(ColumnNames.CantExistente, Value)
            End Set
        End Property

        Public Overridable Property CostoMaterial As Decimal
            Get
                Return MyBase.GetDecimal(ColumnNames.CostoMaterial)
            End Get
            Set(ByVal Value As Decimal)
                MyBase.SetDecimal(ColumnNames.CostoMaterial, Value)
            End Set
        End Property

        Public Overridable Property CodProveedor As Integer
            Get
                Return MyBase.GetInt(ColumnNames.CodProveedor)
            End Get
            Set(ByVal Value As Integer)
                MyBase.SetInt(ColumnNames.CodProveedor, Value)
            End Set
        End Property

        Public Overridable Property CantMinima As Integer
            Get
                Return MyBase.GetInt(ColumnNames.CantMinima)
            End Get
            Set(ByVal Value As Integer)
                MyBase.SetInt(ColumnNames.CantMinima, Value)
            End Set
        End Property

        Public Overridable Property CantMaxima As Integer
            Get
                Return MyBase.GetInt(ColumnNames.CantMaxima)
            End Get
            Set(ByVal Value As Integer)
                MyBase.SetInt(ColumnNames.CantMaxima, Value)
            End Set
        End Property

        Public Overridable Property CodUsuario As Integer
            Get
                Return MyBase.GetInt(ColumnNames.CodUsuario)
            End Get
            Set(ByVal Value As Integer)
                MyBase.Setint(ColumnNames.CodUsuario, Value)
            End Set
        End Property

		Public Overridable Property FechaActualizacion As DateTime
			Get
				Return MyBase.GetDateTime(ColumnNames.FechaActualizacion)
			End Get
			Set(ByVal Value As DateTime)
				MyBase.SetDateTime(ColumnNames.FechaActualizacion, Value)
			End Set
		End Property


	#End Region  
	
	#Region "String Properties" 

		Public Overridable Property s_CodMaterial As String
			Get
				If Me.IsColumnNull(ColumnNames.CodMaterial) Then
					Return String.Empty
				Else
                    Return MyBase.GetintAsString(ColumnNames.CodMaterial)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.CodMaterial)
				Else
                    Me.CodMaterial = MyBase.SetintAsString(ColumnNames.CodMaterial, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_CodTipoMaterial As String
			Get
				If Me.IsColumnNull(ColumnNames.CodTipoMaterial) Then
					Return String.Empty
				Else
                    Return MyBase.GetintAsString(ColumnNames.CodTipoMaterial)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.CodTipoMaterial)
				Else
                    Me.CodTipoMaterial = MyBase.SetintAsString(ColumnNames.CodTipoMaterial, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_DescMaterial As String
			Get
				If Me.IsColumnNull(ColumnNames.DescMaterial) Then
					Return String.Empty
				Else
					Return MyBase.GetStringAsString(ColumnNames.DescMaterial)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.DescMaterial)
				Else
					Me.DescMaterial = MyBase.SetStringAsString(ColumnNames.DescMaterial, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_CantExistente As String
			Get
				If Me.IsColumnNull(ColumnNames.CantExistente) Then
					Return String.Empty
				Else
					Return MyBase.GetDecimalAsString(ColumnNames.CantExistente)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.CantExistente)
				Else
					Me.CantExistente = MyBase.SetDecimalAsString(ColumnNames.CantExistente, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_CostoMaterial As String
			Get
				If Me.IsColumnNull(ColumnNames.CostoMaterial) Then
					Return String.Empty
				Else
					Return MyBase.GetDecimalAsString(ColumnNames.CostoMaterial)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.CostoMaterial)
				Else
					Me.CostoMaterial = MyBase.SetDecimalAsString(ColumnNames.CostoMaterial, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_CodProveedor As String
			Get
				If Me.IsColumnNull(ColumnNames.CodProveedor) Then
					Return String.Empty
				Else
                    Return MyBase.GetintAsString(ColumnNames.CodProveedor)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.CodProveedor)
				Else
                    Me.CodProveedor = MyBase.SetintAsString(ColumnNames.CodProveedor, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_CantMinima As String
			Get
				If Me.IsColumnNull(ColumnNames.CantMinima) Then
					Return String.Empty
				Else
                    Return MyBase.GetintAsString(ColumnNames.CantMinima)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.CantMinima)
				Else
                    Me.CantMinima = MyBase.SetintAsString(ColumnNames.CantMinima, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_CantMaxima As String
			Get
				If Me.IsColumnNull(ColumnNames.CantMaxima) Then
					Return String.Empty
				Else
                    Return MyBase.GetintAsString(ColumnNames.CantMaxima)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.CantMaxima)
				Else
                    Me.CantMaxima = MyBase.SetintAsString(ColumnNames.CantMaxima, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_CodUsuario As String
			Get
				If Me.IsColumnNull(ColumnNames.CodUsuario) Then
					Return String.Empty
				Else
                    Return MyBase.GetintAsString(ColumnNames.CodUsuario)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.CodUsuario)
				Else
                    Me.CodUsuario = MyBase.SetintAsString(ColumnNames.CodUsuario, Value)
				End If
			End Set
		End Property

		Public Overridable Property s_FechaActualizacion As String
			Get
				If Me.IsColumnNull(ColumnNames.FechaActualizacion) Then
					Return String.Empty
				Else
					Return MyBase.GetDateTimeAsString(ColumnNames.FechaActualizacion)
				End If
			End Get
			Set(ByVal Value As String)
				If String.Empty = value Then
					Me.SetColumnNull(ColumnNames.FechaActualizacion)
				Else
					Me.FechaActualizacion = MyBase.SetDateTimeAsString(ColumnNames.FechaActualizacion, Value)
				End If
			End Set
		End Property


	#End Region  	

	#Region "Where Clause"
    Public Class WhereClause

        Public Sub New(ByVal entity As BusinessEntity)
            Me._entity = entity
        End Sub
		
		Public ReadOnly Property TearOff As TearOffWhereParameter
			Get
				If _tearOff Is Nothing Then
					_tearOff = new TearOffWhereParameter(Me)
				End If

				Return _tearOff
			End Get
		End Property

		#Region "TearOff's"
		Public class TearOffWhereParameter

			Public Sub New(ByVal clause As WhereClause)
				Me._clause = clause
			End Sub
		
	
			Public ReadOnly Property CodMaterial() As WhereParameter
				Get
					Dim where As WhereParameter = New WhereParameter(ColumnNames.CodMaterial, Parameters.CodMaterial)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property CodTipoMaterial() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.CodTipoMaterial, Parameters.CodTipoMaterial)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property DescMaterial() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.DescMaterial, Parameters.DescMaterial)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property CantExistente() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.CantExistente, Parameters.CantExistente)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property CostoMaterial() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.CostoMaterial, Parameters.CostoMaterial)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property CodProveedor() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.CodProveedor, Parameters.CodProveedor)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property CantMinima() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.CantMinima, Parameters.CantMinima)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property CantMaxima() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.CantMaxima, Parameters.CantMaxima)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property CodUsuario() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.CodUsuario, Parameters.CodUsuario)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property FechaActualizacion() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.FechaActualizacion, Parameters.FechaActualizacion)
                        Me._clause._entity.Query.AddWhereParameter(where)
                        Return where
                    End Get
                End Property


			Private _clause as WhereClause
		End Class
		#End Region	

		Public ReadOnly Property CodMaterial() As WhereParameter 
			Get
				If _CodMaterial_W Is Nothing Then
					_CodMaterial_W = TearOff.CodMaterial
				End If
				Return _CodMaterial_W
			End Get
		End Property

		Public ReadOnly Property CodTipoMaterial() As WhereParameter 
			Get
				If _CodTipoMaterial_W Is Nothing Then
					_CodTipoMaterial_W = TearOff.CodTipoMaterial
				End If
				Return _CodTipoMaterial_W
			End Get
		End Property

		Public ReadOnly Property DescMaterial() As WhereParameter 
			Get
				If _DescMaterial_W Is Nothing Then
					_DescMaterial_W = TearOff.DescMaterial
				End If
				Return _DescMaterial_W
			End Get
		End Property

		Public ReadOnly Property CantExistente() As WhereParameter 
			Get
				If _CantExistente_W Is Nothing Then
					_CantExistente_W = TearOff.CantExistente
				End If
				Return _CantExistente_W
			End Get
		End Property

		Public ReadOnly Property CostoMaterial() As WhereParameter 
			Get
				If _CostoMaterial_W Is Nothing Then
					_CostoMaterial_W = TearOff.CostoMaterial
				End If
				Return _CostoMaterial_W
			End Get
		End Property

		Public ReadOnly Property CodProveedor() As WhereParameter 
			Get
				If _CodProveedor_W Is Nothing Then
					_CodProveedor_W = TearOff.CodProveedor
				End If
				Return _CodProveedor_W
			End Get
		End Property

		Public ReadOnly Property CantMinima() As WhereParameter 
			Get
				If _CantMinima_W Is Nothing Then
					_CantMinima_W = TearOff.CantMinima
				End If
				Return _CantMinima_W
			End Get
		End Property

		Public ReadOnly Property CantMaxima() As WhereParameter 
			Get
				If _CantMaxima_W Is Nothing Then
					_CantMaxima_W = TearOff.CantMaxima
				End If
				Return _CantMaxima_W
			End Get
		End Property

		Public ReadOnly Property CodUsuario() As WhereParameter 
			Get
				If _CodUsuario_W Is Nothing Then
					_CodUsuario_W = TearOff.CodUsuario
				End If
				Return _CodUsuario_W
			End Get
		End Property

		Public ReadOnly Property FechaActualizacion() As WhereParameter 
			Get
				If _FechaActualizacion_W Is Nothing Then
					_FechaActualizacion_W = TearOff.FechaActualizacion
				End If
				Return _FechaActualizacion_W
			End Get
		End Property

		Private _CodMaterial_W As WhereParameter = Nothing
		Private _CodTipoMaterial_W As WhereParameter = Nothing
		Private _DescMaterial_W As WhereParameter = Nothing
		Private _CantExistente_W As WhereParameter = Nothing
		Private _CostoMaterial_W As WhereParameter = Nothing
		Private _CodProveedor_W As WhereParameter = Nothing
		Private _CantMinima_W As WhereParameter = Nothing
		Private _CantMaxima_W As WhereParameter = Nothing
		Private _CodUsuario_W As WhereParameter = Nothing
		Private _FechaActualizacion_W As WhereParameter = Nothing

			Public Sub WhereClauseReset()

			_CodMaterial_W = Nothing
			_CodTipoMaterial_W = Nothing
			_DescMaterial_W = Nothing
			_CantExistente_W = Nothing
			_CostoMaterial_W = Nothing
			_CodProveedor_W = Nothing
			_CantMinima_W = Nothing
			_CantMaxima_W = Nothing
			_CodUsuario_W = Nothing
			_FechaActualizacion_W = Nothing
				Me._entity.Query.FlushWhereParameters()

			End Sub
	
		Private _entity As BusinessEntity
		Private _tearOff As TearOffWhereParameter
    End Class	

	Public ReadOnly Property Where() As WhereClause
		Get
			If _whereClause Is Nothing Then
				_whereClause = New WhereClause(Me)
			End If
	
			Return _whereClause
		End Get
	End Property
	
	Private _whereClause As WhereClause = Nothing	
#End Region	

#Region "Aggregate Clause"
    Public Class AggregateClause

        Public Sub New(ByVal entity As BusinessEntity)
            Me._entity = entity
        End Sub
		
		Public ReadOnly Property TearOff As TearOffAggregateParameter
			Get
				If _tearOff Is Nothing Then
					_tearOff = new TearOffAggregateParameter(Me)
				End If

				Return _tearOff
			End Get
		End Property

		#Region "AggregateParameter TearOff's"
		Public class TearOffAggregateParameter

			Public Sub New(ByVal clause As AggregateClause)
				Me._clause = clause
			End Sub
		
	
		Public ReadOnly Property CodMaterial() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.CodMaterial, Parameters.CodMaterial)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property CodTipoMaterial() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.CodTipoMaterial, Parameters.CodTipoMaterial)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property DescMaterial() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.DescMaterial, Parameters.DescMaterial)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property CantExistente() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.CantExistente, Parameters.CantExistente)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property CostoMaterial() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.CostoMaterial, Parameters.CostoMaterial)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property CodProveedor() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.CodProveedor, Parameters.CodProveedor)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property CantMinima() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.CantMinima, Parameters.CantMinima)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property CantMaxima() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.CantMaxima, Parameters.CantMaxima)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property CodUsuario() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.CodUsuario, Parameters.CodUsuario)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property

		Public ReadOnly Property FechaActualizacion() As AggregateParameter
			Get
				Dim where As AggregateParameter = New AggregateParameter(ColumnNames.FechaActualizacion, Parameters.FechaActualizacion)
				Me._clause._entity.Query.AddAggregateParameter(where)
				Return where
			End Get
		End Property


			Private _clause as AggregateClause
		End Class
		#End Region	

		Public ReadOnly Property CodMaterial() As AggregateParameter 
			Get
				If _CodMaterial_W Is Nothing Then
					_CodMaterial_W = TearOff.CodMaterial
				End If
				Return _CodMaterial_W
			End Get
		End Property

		Public ReadOnly Property CodTipoMaterial() As AggregateParameter 
			Get
				If _CodTipoMaterial_W Is Nothing Then
					_CodTipoMaterial_W = TearOff.CodTipoMaterial
				End If
				Return _CodTipoMaterial_W
			End Get
		End Property

		Public ReadOnly Property DescMaterial() As AggregateParameter 
			Get
				If _DescMaterial_W Is Nothing Then
					_DescMaterial_W = TearOff.DescMaterial
				End If
				Return _DescMaterial_W
			End Get
		End Property

		Public ReadOnly Property CantExistente() As AggregateParameter 
			Get
				If _CantExistente_W Is Nothing Then
					_CantExistente_W = TearOff.CantExistente
				End If
				Return _CantExistente_W
			End Get
		End Property

		Public ReadOnly Property CostoMaterial() As AggregateParameter 
			Get
				If _CostoMaterial_W Is Nothing Then
					_CostoMaterial_W = TearOff.CostoMaterial
				End If
				Return _CostoMaterial_W
			End Get
		End Property

		Public ReadOnly Property CodProveedor() As AggregateParameter 
			Get
				If _CodProveedor_W Is Nothing Then
					_CodProveedor_W = TearOff.CodProveedor
				End If
				Return _CodProveedor_W
			End Get
		End Property

		Public ReadOnly Property CantMinima() As AggregateParameter 
			Get
				If _CantMinima_W Is Nothing Then
					_CantMinima_W = TearOff.CantMinima
				End If
				Return _CantMinima_W
			End Get
		End Property

		Public ReadOnly Property CantMaxima() As AggregateParameter 
			Get
				If _CantMaxima_W Is Nothing Then
					_CantMaxima_W = TearOff.CantMaxima
				End If
				Return _CantMaxima_W
			End Get
		End Property

		Public ReadOnly Property CodUsuario() As AggregateParameter 
			Get
				If _CodUsuario_W Is Nothing Then
					_CodUsuario_W = TearOff.CodUsuario
				End If
				Return _CodUsuario_W
			End Get
		End Property

		Public ReadOnly Property FechaActualizacion() As AggregateParameter 
			Get
				If _FechaActualizacion_W Is Nothing Then
					_FechaActualizacion_W = TearOff.FechaActualizacion
				End If
				Return _FechaActualizacion_W
			End Get
		End Property

		Private _CodMaterial_W As AggregateParameter = Nothing
		Private _CodTipoMaterial_W As AggregateParameter = Nothing
		Private _DescMaterial_W As AggregateParameter = Nothing
		Private _CantExistente_W As AggregateParameter = Nothing
		Private _CostoMaterial_W As AggregateParameter = Nothing
		Private _CodProveedor_W As AggregateParameter = Nothing
		Private _CantMinima_W As AggregateParameter = Nothing
		Private _CantMaxima_W As AggregateParameter = Nothing
		Private _CodUsuario_W As AggregateParameter = Nothing
		Private _FechaActualizacion_W As AggregateParameter = Nothing

		Public Sub AggregateClauseReset()

		_CodMaterial_W = Nothing
		_CodTipoMaterial_W = Nothing
		_DescMaterial_W = Nothing
		_CantExistente_W = Nothing
		_CostoMaterial_W = Nothing
		_CodProveedor_W = Nothing
		_CantMinima_W = Nothing
		_CantMaxima_W = Nothing
		_CodUsuario_W = Nothing
		_FechaActualizacion_W = Nothing
			Me._entity.Query.FlushAggregateParameters()

		End Sub
	
		Private _entity As BusinessEntity
		Private _tearOff As TearOffAggregateParameter
    End Class	

	Public ReadOnly Property Aggregate() As AggregateClause
		Get
			If _aggregateClause Is Nothing Then
				_aggregateClause = New AggregateClause(Me)
			End If
	
			Return _aggregateClause
		End Get
	End Property
	
	Private _aggregateClause As AggregateClause = Nothing	
#End Region	

	Protected Overrides Function GetInsertCommand() As IDbCommand
	
		Dim cmd As SqlCommand = New SqlCommand
		cmd.CommandType = CommandType.StoredProcedure
		cmd.CommandText = "[" + Me.SchemaStoredProcedure + "proc_MATERIALESInsert]" 
	    
		CreateParameters(cmd)
		
		Dim p As SqlParameter
		p = cmd.Parameters(Parameters.CodMaterial.ParameterName)
		p.Direction = ParameterDirection.Output
    
		Return cmd 

  	End Function
	
	Protected Overrides Function GetUpdateCommand() As IDbCommand
	
		Dim cmd As SqlCommand = New SqlCommand
		cmd.CommandType = CommandType.StoredProcedure    
		cmd.CommandText = "[" + Me.SchemaStoredProcedure + "proc_MATERIALESUpdate]" 
		
		CreateParameters(cmd) 
		    
		Return cmd
	
	End Function	
	
	Protected Overrides Function GetDeleteCommand() As IDbCommand
	
		Dim cmd As SqlCommand = New SqlCommand
		cmd.CommandType = CommandType.StoredProcedure    
		cmd.CommandText = "[" + Me.SchemaStoredProcedure + "proc_MATERIALESDelete]" 
		
		Dim p As SqlParameter
		p = cmd.Parameters.Add(Parameters.CodMaterial)
		p.SourceColumn = ColumnNames.CodMaterial
		p.SourceVersion = DataRowVersion.Current

  
		Return cmd
	
	End Function	
	
	Private Sub CreateParameters(ByVal cmd As SqlCommand)
	
		Dim p As SqlParameter
		p = cmd.Parameters.Add(Parameters.CodMaterial)
		p.SourceColumn = ColumnNames.CodMaterial
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.CodTipoMaterial)
		p.SourceColumn = ColumnNames.CodTipoMaterial
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.DescMaterial)
		p.SourceColumn = ColumnNames.DescMaterial
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.CantExistente)
		p.SourceColumn = ColumnNames.CantExistente
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.CostoMaterial)
		p.SourceColumn = ColumnNames.CostoMaterial
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.CodProveedor)
		p.SourceColumn = ColumnNames.CodProveedor
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.CantMinima)
		p.SourceColumn = ColumnNames.CantMinima
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.CantMaxima)
		p.SourceColumn = ColumnNames.CantMaxima
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.CodUsuario)
		p.SourceColumn = ColumnNames.CodUsuario
		p.SourceVersion = DataRowVersion.Current

		p = cmd.Parameters.Add(Parameters.FechaActualizacion)
		p.SourceColumn = ColumnNames.FechaActualizacion
		p.SourceVersion = DataRowVersion.Current


	End Sub	

End Class

End NameSpace

